package com.tz.entity;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "SHOP_PRODUCT")
public class Product extends BaseEntity {

    private static final long serialVersionUID = 2975045224949360527L;

    //商品名称
    private String name;
    //商品附属标签
    private String subName;
    //价格
    private double price;
    //折扣
    private double discount;
    //税
    private double tax;
    //商品描述
    private String desc;
    //图片集合
    private List<Picture> pictures;
    //库存
    private int stock;
    //商品细节
    private String detail;
    //商品颜色
    private String color;
    //商品分类
    private Category category;
    //是否属于主打产品
    private boolean featured;
    //是否属于最新上架
    private boolean latest;
    //是否在边栏位置推荐
    private boolean sidebar;

    public Product() {
    }

    public Product(String name, double price) {
        this.name = name;
        this.price = price;
    }

    @Column(name = "p_name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "p_subName")
    public String getSubName() {
        return subName;
    }

    public void setSubName(String subName) {
        this.subName = subName;
    }

    @Column(name = "p_price")
    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Column(name = "p_discount")
    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    @Column(name = "p_tax")
    public double getTax() {
        return tax;
    }

    public void setTax(double tax) {
        this.tax = tax;
    }

    @Column(name = "p_desc", length = 1024)
    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @OneToMany
    @JoinColumn(name = "product_id")
    public List<Picture> getPictures() {
        return pictures;
    }

    public void setPictures(List<Picture> pictures) {
        this.pictures = pictures;
    }

    @Column(name = "p_stock")
    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    @Column(name = "p_detail")
    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @Column(name = "p_color")
    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Column(name = "p_is_featured")
    public boolean isFeatured() {
        return featured;
    }

    public void setFeatured(boolean featured) {
        this.featured = featured;
    }

    @Column(name = "p_is_latest")
    public boolean isLatest() {
        return latest;
    }

    public void setLatest(boolean latest) {
        this.latest = latest;
    }

    @Column(name = "p_is_sidebar")
    public boolean isSidebar() {
        return sidebar;
    }

    public void setSidebar(boolean sidebar) {
        this.sidebar = sidebar;
    }

    @ManyToOne
    @JoinColumn(name = "category_id")
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public String toString() {
        return "Product{" +
                ", name='" + name + '\'' +
                ", subName='" + subName + '\'' +
                ", price=" + price +
                ", discount=" + discount +
                ", tax=" + tax +
                ", desc='" + desc + '\'' +
                ", stock=" + stock +
                ", detail='" + detail + '\'' +
                ", color='" + color + '\'' +
                ", featured=" + featured +
                ", latest=" + latest +
                ", sidebar=" + sidebar +
                '}';
    }
}
